﻿/*
 * Authors:
 *   钟峰(Popeye Zhong) <9555843@qq.com>
 *
 * Copyright (c) 2017 Flagwind Game Studio. All rights reserved.
 */

using System;
using System.Collections.Generic;

namespace Flagwind.Gaming
{
    public class GameRoom
	{
		#region 成员字段
		private uint _roomId;
		private uint _roomTypeId;
		private uint _expiry;
		private uint _renterId;
		private DateTime _rentedTime;
		private GameRound _round;
		private Player[] _players;
		#endregion

		#region 属性定义
		/// <summary>
		/// 获取或设置游戏房间编号。
		/// </summary>
		public uint RoomId
		{
			get
			{
				return _roomId;
			}
			set
			{
				_roomId = value;
			}
		}

		/// <summary>
		/// 获取或设置房间类型编号。
		/// </summary>
		public uint RoomTypeId
		{
			get
			{
				return _roomTypeId;
			}
			set
			{
				_roomTypeId = value;
			}
		}

		/// <summary>
		/// 获取或设置房间的过期时段（单位为分钟），零表示临时房。
		/// </summary>
		public uint Expiry
		{
			get
			{
				return _expiry;
			}
			set
			{
				_expiry = value;
			}
		}

		/// <summary>
		/// 获取或设置开房人编号。
		/// </summary>
		public uint RenterId
		{
			get
			{
				return _renterId;
			}
			set
			{
				_renterId = value;
			}
		}

		/// <summary>
		/// 获取或设置开房的时间。
		/// </summary>
		public DateTime RentedTime
		{
			get
			{
				return _rentedTime;
			}
			set
			{
				_rentedTime = value;
			}
		}

		/// <summary>
		/// 获取一个值，指示当前游戏房是否空闲的，即台桌尚未满员。
		/// </summary>
		public bool IsIdle
		{
			get
			{
				if(_players == null)
					return true;

				foreach(var player in _players)
				{
					if(player == null)
						return true;
				}

				return false;
			}
		}

		/// <summary>
		/// 获取一个值，指示当前游戏台是否正在进行游戏。
		/// </summary>
		public bool IsPlaying
		{
			get
			{
				return _round != null;
			}
		}

		/// <summary>
		/// 获取或设置当前正在进行中的牌局。
		/// </summary>
		public GameRound Round
		{
			get
			{
				return _round;
			}
			set
			{
				_round = value;
			}
		}

		/// <summary>
		/// 获取或设置房间内的玩家数组。
		/// </summary>
		public Player[] Players
		{
			get
			{
				return _players;
			}
			set
			{
				_players = value;
			}
		}
		#endregion

	}
}
